﻿Imports System.Speech.Synthesis

Public Class Datos

    Dim voz As New SpeechSynthesizer


    Private Sub Datos_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Try

            DataGridView1.DataSource = (From ti In union.GestionEnCola
                                        Select ti.IdGestionEnCola, ti.CodGestion, ti.Gestion.NombreGestion, ti.Secuencia, ti.FechaPeticion, ti.FechaAtencion, Estado = ti.Estado.Estado).ToList

        Catch ex As Exception

        End Try


    End Sub





    Private Sub btnLlamar_Click(sender As Object, e As EventArgs) Handles btnLlamar.Click

       
        Dim CodGes As String = DataGridView1.CurrentRow().Cells(1).Value
        Dim secuen As Integer = DataGridView1.CurrentRow().Cells(3).Value
        Dim ticket As String = String.Format("Ticket {0} - Ventanilla {1}", CodGes, secuen)
        Dim IdTicket As Integer = DataGridView1.CurrentRow().Cells(0).Value 'es por la posicion en la que se encuntra la posicion

        '.Rate velocidad en la que se pronuncioara la voz
        With voz
            .Rate = -1
            .SetOutputToDefaultAudioDevice()
            .SpeakAsync(String.Format("ticket , {0}, {1}, Pasar a ventanilla 1", separar(CodGes), secuen))
        End With

        Dim tick = (From t In union.GestionEnCola
                            Where t.IdGestionEnCola = IdTicket
                            Select t).SingleOrDefault()

        With tick

            .IdEstado = 2
            .FechaAtencion = Date.Now

        End With

      


        union.SubmitChanges()
        CargarTicket()

    End Sub


    Function separar(texto As String) As String

        For i As Integer = texto.Length - 1 To 1 Step -1
            texto = texto.Insert(i, " ")

        Next

        Return texto

    End Function
   
    Public Sub CargarTicket()
        DataGridView1.DataSource = (From ti In union.GestionEnCola
                                        Select ti.IdGestionEnCola, ti.CodGestion, ti.Gestion.NombreGestion, ti.Secuencia, ti.FechaPeticion, ti.FechaAtencion, Estado = ti.Estado.Estado).ToList()

    End Sub

    Private Sub ActualizarToolStripMenuItem_Click(sender As Object, e As EventArgs)

    End Sub
End Class